<?php

require_once(sfConfig::get('sf_lib_dir').'/filter/base/BaseFormFilterPropel.class.php');

/**
 * Clientes filter form base class.
 *
 * @package    tercermilenio
 * @subpackage filter
 * @author     Your name here
 */
class BaseClientesFormFilter extends BaseFormFilterPropel
{
  public function setup()
  {
    $this->setWidgets(array(
      'cli_nro_documento' => new sfWidgetFormFilterInput(),
      'cli_nombre'        => new sfWidgetFormFilterInput(),
      'cli_localidad'     => new sfWidgetFormPropelChoice(array('model' => 'Localidades', 'add_empty' => true)),
      'cli_direccion'     => new sfWidgetFormFilterInput(),
      'cli_telefono'      => new sfWidgetFormFilterInput(),
      'cli_celular'       => new sfWidgetFormFilterInput(),
      'cli_estado'        => new sfWidgetFormFilterInput(),
      'cli_credito'       => new sfWidgetFormFilterInput(),
    ));

    $this->setValidators(array(
      'cli_nro_documento' => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'cli_nombre'        => new sfValidatorPass(array('required' => false)),
      'cli_localidad'     => new sfValidatorPropelChoice(array('required' => false, 'model' => 'Localidades', 'column' => 'loc_id')),
      'cli_direccion'     => new sfValidatorPass(array('required' => false)),
      'cli_telefono'      => new sfValidatorPass(array('required' => false)),
      'cli_celular'       => new sfValidatorPass(array('required' => false)),
      'cli_estado'        => new sfValidatorPass(array('required' => false)),
      'cli_credito'       => new sfValidatorSchemaFilter('text', new sfValidatorNumber(array('required' => false))),
    ));

    $this->widgetSchema->setNameFormat('clientes_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    parent::setup();
  }

  public function getModelName()
  {
    return 'Clientes';
  }

  public function getFields()
  {
    return array(
      'cli_id'            => 'Number',
      'cli_nro_documento' => 'Number',
      'cli_nombre'        => 'Text',
      'cli_localidad'     => 'ForeignKey',
      'cli_direccion'     => 'Text',
      'cli_telefono'      => 'Text',
      'cli_celular'       => 'Text',
      'cli_estado'        => 'Text',
      'cli_credito'       => 'Number',
    );
  }
}
